@extends('layouts.back_stage')
@section('style')
    @parent
    <link href="{{env('CDN_DOMAIN_NAME')}}/css/customers.css" rel="stylesheet">
    <link href="{{env('CDN_DOMAIN_NAME')}}/css/daterangepicker-bs3.css" rel="stylesheet">
@endsection
@section('content')
    <div class="container">
        <div class="container_box">
            <div class="chartshead">
                {{--<h1>收入查询</h1>--}}
                <a href="/finance/statisticAnalysis" class="chartshead_sum">财务汇总</a>
                <a href="/finance" class="chartshead_index">返回</a>
            </div>
            <form  name="d_reg_form" action="/finance/allIncome"  >
                    <div class="all_income_select_conditions">
                        <div class="all_income_select_conditions_time">
                            <p>交易时间：</p>
                            <div class="time_custom input-prepend input-group">
                                <input type="text" readonly style="width: 200px" name="reservation" id="reservation" class="form-control" value="{{$time}}" placeholder="选择查询时间" />
                            </div>
                        </div>
                        @if(Auth('admin')->user()->company_id == 1)
                        <div class="all_income_select_conditions_brandinfo" style="height:80px;">
                            <p>公司名称：</p>
                            <select name="company" id="company" class="form-control pro_select">
                                @if(isset($_GET['company']) && $_GET['company'] )
                                    <option value="{{$_GET['company']}}">{{ $companys[$_GET['company']] }}</option>
                                @else
                                    <option value="">请选择</option>
                                @endif
                                @foreach($companys as $k=>$v)
                                <option value="{{ $k }}">{{ $v }}</option>
                                @endforeach
                            </select>
                        </div>
                        @endif
                        <div class="all_income_select_conditions_brandinfo">
                            <p>品牌名称：</p>
                            <select name="brand" id="brand" class="form-control pro_select">
                                @if(isset($_GET['brand']) && $_GET['brand'])
                                    <option value={{$_GET['brand']}}>{{ $brands[$_GET['brand']] }}</option>
                                    @else
                                    <option value="">请选择</option>
                                @endif
                                @foreach ($brands as $k=>$v)
                                    <option value={{$k}}>{{ $v }}</option>
                                @endforeach
                            </select>

                        </div>
                        <div class="all_income_select_conditions_custormers_name" style="height:80px;">
                            <p>款号名称：</p>
                            <input class="form-control customer_tel" name="item" placeholder="输入款号（选填）" />
                        </div>
                        <div class="all_income_select_conditions_custormers_name">
                            <p>客户信息：</p>
                            @if(isset($_GET['name']))
                            <input class="form-control customer_tel" name="name" value="{{ $_GET['name'] }}" placeholder="用户姓名（选填）" />
                            @else
                            <input class="form-control customer_tel" name="name"  placeholder="用户姓名（选填）" />
                            @endif
                        </div>
                        <button type="submit" class="all_income_serach" >查询</button>
                    </div>
            </form>
            <table border="0" cellspacing="0" class="all_income_info">
                        <thead>
                        <tr><!--固定栏-->
                            <th>收款时间</th>
                            <th>客户姓名</th>
                            <th>订单号</th>
                            <th>所在大区</th>
                            <th>品牌名称</th>
                            <th>款式</th>
                            <th>款号</th>
                            <th>数量</th>
                            <th>商品金额</th>
                            <th>折扣</th>
                            <th>优惠金额</th>
                            <th>收款金额</th>
                        </tr>
                        </thead>
                        <tbody class="pageDiv">
                        @foreach($orders as $order)
                        <tr>
                            <td>{{$order->successed_at}}</td>
                            <td>{{$order->addressee_name}}</td>
                            <td>{{$order->ordernum}}</td>
                            <td>{{strstr($order->addressee_place,' ',true)}}</td>
                            <td>{{$order->brand_name}}</td>
                            <td>{{$order->color}}</td>
                            <td>{{$order->girard}}</td>
                            <td>{{$order->num}}</td>
                            <td>{{number_format($order->total_price,2)}}</td>
                            <td>{{number_format($order->total_price-$order->actual_price,2)}}</td>
                            <td>{{number_format($order->actual_price/$order->total_price,2)}}</td>
                            <td>{{number_format($order->actual_price,2)}}</td>
                        </tr>
                        @endforeach
                        </tbody>
                    </table>
                <div style="float: right">{{ $orders->appends(['reservation'=>$time,'brand'=>$brand_id,'item'=>$item])->links() }}</div>

        </div>
    </div>
    <script type="text/JavaScript">
        function valueChange(){
            var objS = document.getElementById("income_select_time");
            var value = objS.options[objS.selectedIndex].value;
            if(value == "自定义"){
                $(".time_custom").css('display','block')
            }else{
                $(".time_custom").css('display','none')
            }
        }
//        function  check() {
//            if(!(/^1[34578]\d{9}$/.test($(".customer_tel").val()))){
//                alert("手机号码有误，请重填");
//                return false;
//            }
//        }
    </script>
    <script type="text/javascript">/*日期选择器*/
        $(document).ready(function() {
            $('#reservation').daterangepicker(null, function(start, end, label) {
                console.log(start.toISOString(), end.toISOString(), label);
            });
        });
    </script>
@endsection
@section('script')
    @parent
    <script src="{{ env('CDN_DOMAIN_NAME') }}/js/moment.js" type="text/javascript"></script>
    <script src="{{ env('CDN_DOMAIN_NAME') }}/js/daterangepicker.js" type="text/javascript"></script>
    <script type="text/javascript">
    </script>
@endsection